<?php

define('WHITEBOARD_ALBUM_SUBTYPE', 'album');
define('WHITEBOARD_ALBUM_TITLE', 'Whiteboard');
define('WHITEBOARD_ALBUM_DESC', 'Whiteboard album');
define('WHITEBOARD_ALBUM_METADATA', 'whiteboardalbum');

class WhiteboardAlbum extends TidypicsAlbum {

    protected function initialise_attributes() {
        parent::initialise_attributes();

        $this->attributes['subtype'] = WHITEBOARD_ALBUM_SUBTYPE;
        $this->attributes['access_id'] = ACCESS_PUBLIC;
    }

    public function __construct($guid = null) {
        parent::__construct($guid);
    }

    public function saveAlbum($attributes = array(), $metadata = array(), $annotations = array()) {
        foreach ($attributes as $k => $v)
            $this->set($k, $v);
        
        if (!parent::save()) {
            return false;
        }

        $this->setMetaData('new_album', TP_NEW_ALBUM);
        $this->setMetaData(WHITEBOARD_ALBUM_METADATA, 1);
        foreach ($metadata as $k => $v)
            $this->setMetaData($k, $v);

        foreach ($annotations as $k => $v)
            $this->annotate($k, $v);

        return true;
    }
    
    public static function toArray($album) {

        return array(
            'guid' => $album->getGUID(),
            'width' => 0,
            'height' => 0,
            'portrait' => 1,
            'title' => $album->title,
            'description' => $album->description,
            'tags' => $album->getMetaData('tags'),
            'avg_rating' => 3
        );
    }
}